<?php 
	include("protected/back_end_paging.php"); 
	$sql = "SELECT `news`.`News_Id`, `news`.`Title`, Date_FORMAT(`news`.`Date`, '%d/%m/%Y') As `date_add`, `news`.`Description` , `news`.`alias`, `news`.`img_file`, `news`.`img_status`
	FROM `news` WHERE `news`.`Title` like  ?  OR `news`.`Description` like ?
	Order by `news`.`Order` desc";

	$cmd = $mysqli->prepare($sql);
	$strsearch = "%".$_GET["search"]."%";
	$cmd->bind_param("ss", $strsearch, $strsearch);
	$cmd->execute() or die($mysqli->error);
	$cmd->bind_result($News_Id, $Title, $date_add, $Description, $alias, $img_file, $img_status);
	$cmd->store_result();
	if(!isset($_POST["limit"])) $r = 10; else $r = $_POST["limit"];
	if(!isset($_GET["page"])) $p = 1; else $p = $_GET["page"];
	$pager = Pager::getPagerData($cmd->num_rows, $r, $p);
	$i = 1;
	if($cmd->num_rows == 0){?>		
		<div id="box_search_result">
			<div id="sub_box_search_result">
				<div class="bg_tt_right"><div class="bg_tt_left"><div class="bg_tt"><div class="text_tt"> Kết quả tìm</div></div></div></div>
				<div id="sub_box_search_result1">
					<div class="ct_right">
						<div class="ct_left">
							<div class="ct">
								không có kết quả nào được tìm thấy cho từ khóa <em><strong><?php echo $_GET["search"]?></strong></em>
							</div>
						</div>
					</div>
					<div class="bg_bt_right"><div class="bg_bt_left"><div class="bg_bt"><div class="text_bt"></div></div></div></div>
				</div>
			</div>
			<div class="clear"></div>
		</div>
	<?php } else {?>
		<div id="box_search_result">
			<div id="sub_box_search_result">
				<div class="bg_tt_right"><div class="bg_tt_left"><div class="bg_tt"><div class="text_tt"> Kết quả tìm</div></div></div></div>
				<div id="sub_box_search_result1">
					<div class="ct_right">
						<div class="ct_left">
							<div class="ct">
								<label style="color:#FF9900;font-weight:bold;font-size:14px;">Tìm thấy <?php echo $cmd->num_rows ?> kết quả cho từ khóa <em><strong> <?php echo $_GET["search"]?></strong></em></label><br><br>						
								<?php while($cmd->fetch()){
									if($i > $pager->offset && $i <= $pager->limit){ ?>
										<div class="category_content">
											<div class="title"><a href="<?php echo "./com_content/article/$alias.csp"; ?>"><?php echo $Title; ?></a></div>
											<div class="date">Cập nhật ngày: <?php echo $date_add; ?></div>
											<div class="content">
												<?php if ($img_status) { echo "<div class=\"news_img\"><a href=./com_content/article/$alias.csp><img width=\"130\" height=\"100\" src=\"$img_file\"></a></div>";}?>
												<div class="news_content"><?php echo $Description; ?></div>
												<div class=clear></div>
											</div>
											<div class=clear></div>
										</div>
									<?php }
									$i++;
								} ?>
							</div>
						</div>
					</div>
					<div class="bg_bt_right"><div class="bg_bt_left"><div class="bg_bt"><div class="text_bt">&nbsp;</div></div></div></div>
				</div>
			</div>
			<div class="clear"></div>
		</div>
	<?php } ?>